﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace BlueLotus7
{
    partial class Validator
    {
        public static bool IsIpV4Address(string ipString)
        {
            if (ipString != null)
            {
                string[] numbers = ipString.Split('.');
                if (numbers != null && numbers.Length == 4)
                {
                    foreach (string num in numbers)
                    {
                        try
                        {
                            int ip = Convert.ToInt32(num);
                            if (ip < 0 || ip > 255)
                            {
                                return false;
                            }
                        }
                        catch
                        {
                            return false;
                        }
                    }
                    return true;
                }
            }
            return false;
        }

        public static bool IsMacAddress(string macAddress)
        {
            if (macAddress != null)
            {
                Regex regex = new Regex("^[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}$");
                if (regex.IsMatch(macAddress.ToUpper()))
                    return true;
            }
            return false;
        }
    }
}
